import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';
import set from '@dfeidao/atom-web/local/set';


export default async function a001(fd: IFeidaoAiBrowserComponent, plan_list_no: string) {
	// 打开窗口
	const n = fd.data.node.querySelector<HTMLDivElement>('[data-id="edit1"]');
	set_node_cls(n, 'display-n', false);
	const res = await nodejs<{ data: { plan_cla_attr_no: string }[]; }>('wangju/zj-000005/s001', {
		plan_list_no
	});
	console.log(res);
	if (res) {
		const plan_cla = await nodejs('wangju/zj-000004/s001', {});
		const data = res.data[0];
		const plan_cla_attr_no = data.plan_cla_attr_no;
		let plan_type = [] as Array<{}>;
		if (plan_cla_attr_no) {
			plan_type = await nodejs<Array<{}>>('wangju/zj-000004/s002', {
				plan_cla_attr_no
			});
		}
		const render_data = Object.assign({ plan_type }, data, plan_cla);
		console.log('数据综合', [render_data]);
		set(fd, 'plan_list_no', plan_list_no)
		render(fd, [render_data], p001, 'p001', 'inner');
	}
}
